//
//  BuyGoodsItemTableViewCell.m
//  JiuJiuShangCheng
//
//  Created by jiujiukeji on 2018/7/30.
//  Copyright © 2018年 jiujiukeji. All rights reserved.
//

#import "BuyGoodsItemTableViewCell.h"

@implementation BuyGoodsItemTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setUpUI];
    }
    return self;
}
- (void)setUpUI
{
    self.backgroundColor = UIColorFromRGB(0xf5f5f5);
    WeakSelf
    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, rateHeight(90))];
    view1.backgroundColor = UIColorWhite;
    [self addSubview:view1];
    
    UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(0, rateHeight(90), kScreenWidth, rateHeight(180))];
    view2.backgroundColor = tableViewBgColor;
    [self addSubview:view2];
    
    UIView *view3 = [[UIView alloc] initWithFrame:CGRectMake(0, rateHeight(270), kScreenWidth, rateHeight(80))];
    view3.backgroundColor = UIColorWhite;
    [self addSubview:view3];
    
    self.goodsImg = [[UIImageView alloc] init];
    _goodsImg.image = UIImageNamed(@"salesGoods");
    [view2 addSubview:_goodsImg];
    [_goodsImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(view2).offset(rateWidth(30));
        make.centerY.equalTo(view2);
        make.size.mas_offset(CGSizeMake(rateWidth(150), rateWidth(150)));
    }];
    
    self.describeLB = [UILabel labelWithText:@"" textColor:UIColorFromRGB(0x666666) fontSize:14];
    _describeLB.numberOfLines = 0;
    [_describeLB sizeToFit];
    [view2 addSubview:_describeLB];
    [_describeLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.goodsImg.mas_right).offset(rateWidth(20));
        make.width.lessThanOrEqualTo(@(rateWidth(300)));
        make.top.equalTo(weakSelf.goodsImg).offset(rateHeight(10));
        make.height.mas_lessThanOrEqualTo(@(rateHeight(100)));
    }];
    self.priceLB = [UILabel labelWithText:@"" textColor:UIColorFromRGB(0x666666) fontSize:14];
    [_priceLB sizeToFit];
    [view2 addSubview:_priceLB];
    [_priceLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(view2).offset(-rateWidth(30));
        make.top.equalTo(weakSelf.goodsImg).offset(rateHeight(10));
    }];
    self.numLB = [UILabel labelWithText:@"×1" textColor:UIColorFromRGB(0x666666) fontSize:14];
    [_numLB sizeToFit];
    [view2 addSubview:_numLB];
    [_numLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.goodsImg.mas_right).offset(rateWidth(20));
        make.top.equalTo(weakSelf.priceLB.mas_bottom).offset(rateHeight(30));
    }];
    
    self.goodsTitleLB = [UILabel labelWithText:@"" textColor:UIColorFromRGB(0x666666) fontSize:14];
    [_goodsTitleLB sizeToFit];
    [view2 addSubview:self.goodsTitleLB];
    [_goodsTitleLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(view2).offset(-rateWidth(30));
        make.centerY.equalTo(self.numLB);
    }];
    
    self.topLB = [UILabel labelWithText:@"" textColor:UIColorFromRGB(0x323232) fontSize:14];
    _topLB.numberOfLines = 0;
    [self.topLB sizeToFit];
    [view1 addSubview:self.topLB];
    [self.topLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(view1).offset(rateWidth(30));
        make.centerY.equalTo(view1);
        make.width.mas_lessThanOrEqualTo(@(kScreenWidth-rateWidth(40)));
    }];
    
    UILabel *label = [UILabel labelWithText:@"" textColor:UIColorFromRGB(0xf55555) fontSize:14];
    [label sizeToFit];
    [view3 addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(view3);
        make.right.equalTo(view3).offset(-rateWidth(40));
    }];
    self.bottomPrice = label;
    
    UIView *line = [[UIView alloc] init];
    line.backgroundColor = globalGray;
    [self addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self);
        make.height.equalTo(@(rateHeight(1)));
    }];
}

@end
